/*
 * @Author: NJ_1098 xiabaoxin
 * @Date: 2025-02-11 13:37:20
 * @LastEditors: NJ_1098 xiabaoxin
 * @LastEditTime: 2025-02-13 15:57:09
 * @Description: http服务
 */
const Koa = require("koa");
const { koaBody } = require("koa-body");
const static = require("koa-static");
const path = require("path");
const app = new Koa();
const cors = require("koa-cors");
const errHandler = require("./errHandler.js");
const routers = require("../router/index.js");
const log = require("../log/index.js");

app.use(
  koaBody({
    multipart: true,
    formidable: {
      maxFieldsSize: 8 * 1024 * 1024,
      multipart: true,
    },
  })
);
app.use(cors());
app.use(log);
app.use(routers());
app.use(static(path.join(__dirname, "../upload")));

app.on("error", errHandler);
module.exports = app;
